{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "0.6675869539565522\n",
      "0.6676\n",
      "a\n",
      "['e']\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "# 随机返回一个 [a,b] 的闭区间内的整数\n",
    "print(random.randint(1,10))\n",
    "\n",
    "# 随机返回一个 [0,1) 的区间内的浮点数\n",
    "random_float = random.random()\n",
    "print(random_float)\n",
    "# 小数精度控制 round()\n",
    "print( round(random_float,4) )\n",
    "\n",
    "# 从给定的序列中随机返回一个\n",
    "print(random.choice(('a','b','c','d','e')))\n",
    "\n",
    "# 从给定的序列中随机返回一个list\n",
    "print(random.choices((('a','b'),('c','d'),'e')))\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "f0831691c6bb6c483f09af1e7987fd76373eadc68cb706017f41b090bfe4d138"
  },
  "kernelspec": {
   "display_name": "Python 3.8.3 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
